package tony.crypto.symmetric

import com.fasterxml.jackson.annotation.JsonCreator
import tony.core.enums.StringEnumValue
import tony.core.enums.getEnum
import tony.crypto.CryptoAlgorithm

/**
 * 对称加密算法
 * @author tangli
 * @date 2023/09/12 19:46
 */
public enum class SymmetricCryptoAlgorithm(
    override val value: String,
    private val algorithm: SymmetricCrypto,
) : StringEnumValue,
    CryptoAlgorithm,
    SymmetricCrypto by algorithm {
    AES("AES", Aes),
    DES("DES", Des),
    SM4("SM4", Sm4),
    ;

    @Suppress("ClassName")
    public companion object `-Companion` {
        @JsonCreator
        @JvmStatic
        public fun create(value: String): SymmetricCryptoAlgorithm? =
            SymmetricCryptoAlgorithm::class.java.getEnum(value.uppercase())
    }
}
